import os
import sqlite3

from fastapi import FastAPI, HTTPException
from fastapi.responses import FileResponse
from pathlib import Path
from config import PROJECT_PATH, DB_PATH

app = FastAPI(title="工程文件索引系统")

def get_db_connection():
    """
    创建SQLite数据库连接
    """
    return sqlite3.connect(DB_PATH)

@app.on_event("startup")
def initialize_system():
    """
    创建索引数据库
    """
    with get_db_connection() as conn:
        conn.execute("""
            CREATE TABLE file_index (
                     id INTEGER
                     )

""")
